/*
 * @Author: 吴世扬 18368095041@163.com
 * @Date: 2024-08-29 17:27:40
 * @LastEditors: 吴世扬 18368095041@163.com
 * @LastEditTime: 2024-09-12 10:13:17
 * @FilePath: /react18-vite-admin/src/api/auth.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { service } from '@/service/app/useRequest';

export const getCaptchaUrl = () => {
    return (
        import.meta.env.VITE_APP_BASE_API +
        '/admin/api/login/captcha?t=' +
        new Date().getTime().toString()
    );
};

export class LoginParam {
    username = '';
    password = '';
    captcha = '';
}
export const login = (data: LoginParam) => {
    return service<HttpResult<string>>({
        url: '/admin/api/login/login',
        method: 'post',
        data
    }).then((res) => {
        return res.data;
    });
};

export const logout = () => {
    return service<HttpResult<string>>({
        url: '/admin/api/login/logout',
        method: 'post'
    }).then((res) => {
        return res.data;
    });
};
